package com.xgp.company.创建型模式.第四种_原型模式.demo2;

import java.util.Date;

/**
 * 1、实现一个接口
 * 2、重写一个方法
 */
//视频原型类
public class Video implements Cloneable {
    private String name;
    private Date createTime;

    /**
     * 重写克隆方法
     * @return
     * @throws CloneNotSupportedException
     */
    @Override
    protected Object clone() throws CloneNotSupportedException {
        /**
         * 改造克隆方法，进行生克隆
         */
        Object obj = super.clone();
        Video v = (Video) obj;

        //将对象的属性进行克隆
        v.createTime = (Date) this.createTime.clone();
        return obj;
    }

    public Video() {

    }

    public Video(String name, Date createTime) {
        this.name = name;
        this.createTime = createTime;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public Date getCreateTime() {
        return createTime;
    }

    public void setCreateTime(Date createTime) {
        this.createTime = createTime;
    }

    @Override
    public String toString() {
        return "Video{" +
                "name='" + name + '\'' +
                ", createTime=" + createTime +
                '}';
    }
}
